//
//  JudgeBackDataCodeMessage.m
//  EasyToTesco2.0
//
//  Created by 袖手旁觀 on 16/6/30.
//  Copyright © 2016年 EasyToTesco. All rights reserved.
//

#import "JudgeBackDataCodeMessage.h"
#import <UIKit/UIKit.h>

@implementation JudgeBackDataCodeMessage

+ (void)JudgeBackDataCodeMessage:(NSString *)message andObjece:(id)object andAddHUDView:(UIView *)view andPopViewController:(CompleteBlock)completeBlock{
    
    if (JudgeBackDataCode) {
        
        MBProgressHUD *hud = [MBProgressHUD showMessage:message toView:view dimBackground:NO AndCompleteBlock:^(id object) {
            
            if (completeBlock) {
                completeBlock(completeBlock);
            }
        }];
        
        [view addSubview:hud];
        
//        if (completeBlock) {
//            completeBlock(object);
//        }
        
    } else {
        NSString *message = [object[@"message"] objectForKey:@"view"];
        
        MBProgressHUD *hud = [MBProgressHUD showMessage:message toView:view dimBackground:NO AndCompleteBlock:nil];
        
        [view addSubview:hud];
    }
}

+ (void)JudgeBackDataCodeMessage:(NSString *)message andObjece:(id)object andAddHUDView:(UIView *)view andPopViewController:(CompleteBlock)completeBlock andBackDataBlock:(CompleteBackDataBlock)backDataBlock {
    
    if (JudgeBackDataCode) {
        
        if (backDataBlock) {
            backDataBlock(object);
        }
        
        MBProgressHUD *hud = [MBProgressHUD showMessage:message toView:view dimBackground:NO AndCompleteBlock:^(id object) {
            if (completeBlock) {
                completeBlock(completeBlock);
            }
        }];
        
        [view addSubview:hud];
        
    } else {
        NSDictionary *message = [object objectForKey:@"message"];
        
        MBProgressHUD *hud = [MBProgressHUD showMessage:message[@"msg"] toView:view dimBackground:NO AndCompleteBlock:nil];
        
        [view addSubview:hud];
    }
    
    
}

@end
